package com.xhh.nphm.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhh.nphm.system.domain.MwfDeferEty;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface MwfDeferDao extends BaseMapper<MwfDeferEty> {
    /**
     * 信件延期申请未审 列表数据
     * @param mwfDeferEty
     * @param deptId
     * @return
     */
    @Select("select PkId,SendID,WfId,WorkFormNO,ADeptName,convert(varchar(10),LimitOld,20) as tmLimit,convert(varchar(19),DelayTo,20) as tmDelay,DelayRN,DeferState,(select SpareString from mMailWorkForm where PkId=mWfDefer.WfId) SpareString from mWfDefer where SDeptID=#{deptId} and DeferState=10 and FkInt <> 1  and IsDel=0 ")
    List<MwfDeferEty> mDeferChkNListJson(@Param("defer") MwfDeferEty mwfDeferEty,@Param("deptId") String deptId);

    /**
     * 信件延期申请未审 列表数据
     * @param mwfDeferEty
     * @param deptId
     * @return
     */
    @Select("select PkId,SendID,WfId,WorkFormNO,ADeptName,convert(varchar(10),LimitOld,20) as tmLimit,convert(varchar(19),DelayTo,20) as tmDelay,DelayRN,DeferState,(select SpareString from mMailWorkForm where PkId=mWfDefer.WfId) SpareString from mWfDefer where SDeptID=#{deptId} and DeferState=10 and FkInt <> 1  and IsDel=0 AND DATEDIFF(day, GETDATE(), LimitOld) > -7 ")
    List<MwfDeferEty> mDeferChkNListJson_gxq(@Param("defer") MwfDeferEty mwfDeferEty,@Param("deptId") String deptId);

    /**
     * 信件延期申请已审 列表数据
     * @param mwfDeferEty
     * @param deptId
     * @return
     */
    @Select("select PkId,SendID,WfId,WorkFormNO,ADeptName,convert(varchar(10),LimitOld,20) as tmLimit,convert(varchar(19),DelayTo,20) as tmDelay,DelayRN,DeferState,convert(varchar(10),CheckTime,20) as tmChk from mWfDefer where SDeptID=#{deptId} and DeferState in (21,22) and FKInt <> 1 and IsDel=0 ")
    List<MwfDeferEty> mDeferChkYListJson(@Param("defer") MwfDeferEty mwfDeferEty,@Param("deptId") String deptId);

    /**
     * 信件待本部门回复 延期数据
     * @param mwfDeferEty
     * @param sendId
     * @return
     */
    @Select("select PkId as myPkVal,WfId,WorkFormNO,SDeptName,SUserName,convert(varchar(19),LimitOld,20) as tmLimit,ADeptName,DelayRN,convert(varchar(19),DelayTo,20) as tmDelay,DeferState,ChkRemark,ChkDesc from mWfDefer where SendID=#{sendId} and IsDel=0")
    List<Map<Object,String>> mwfDeferListJson(MwfDeferEty mwfDeferEty, @Param("sendId") String sendId);
}
